home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Utilitaires divers / Images / Image 1.37 ƒ / Macros / Sleep Studies < prev   
Encoding:
Text File  |  1990-10-16  |  3.9 KB  |  245 lines  |  [TEXT/MSWD]

  1. {Global Variables}
  2. var
  3.   left,top,width,height,HeightOne:integer;
  4.  
  5.  
  6. procedure ImportTemperatureData;
  7. var
  8.   nDays,SamplesPerDay,hScale,vScale,width,height:integer;
  9. begin
  10.   hScale:=2;
  11.   vScale:=10;
  12.   SetImport('Text');
  13.   SetImportMinMax(34,40);
  14.   Import('');       {Prompt for file name}
  15.   GetPicSize(nDays,SamplesPerDay);
  16.   SelectAll;
  17.   Copy;
  18.   Dispose(nPics);
  19.   width:=SamplesPerDay*hScale;
  20.   height:=nDays*vScale;
  21.   SetNewSize(width+80,height+40);
  22.   if DoublePlot then SetNewSize(width*2+80,height+40);
  23.   SetBackgroundColor(0); 
  24.   MakeNewWindow('Temperature Data');
  25.   Paste;
  26.   RestoreRoi;
  27.   RotateLeft;
  28.   FlipVertical;
  29.   ScaleSelection(hScale,vScale);
  30.   RestoreRoi;
  31.   Copy;
  32.   Clear;
  33.   MakeRoi(20,20,width,height);
  34.   Paste;
  35.   if DoublePlot then begin
  36.     MakeRoi(20+width,20-vscale,width,height);
  37.     Paste;
  38.   end;
  39.   KillRoi;
  40. end;
  41.  
  42.  
  43. macro 'Import Temperature Data';
  44. var
  45.   DoublePlot:boolean;
  46. begin
  47.   DoublePlot:=false;
  48.   ImportTemperatureData;
  49. end;
  50.  
  51.  
  52. macro 'Import Temperature - Data Double Plot';
  53. var
  54.   DoublePlot:boolean;
  55. begin
  56.   DoublePlot:=true;
  57.   ImportTemperatureData;
  58. end;
  59.  
  60.  
  61. procedure ImportSleepData;
  62. var
  63.   nDays,SamplesPerDay,hScale,vScale,width,height:integer;
  64.   x,y,RoiWidth,RoiHeight,vloc:integer;
  65. begin
  66.   if DoublePlot then begin
  67.     hScale:=0.125;
  68.     vloc:=20
  69.   end else begin
  70.     hScale:=0.25;
  71.     vloc:=10
  72.   end;
  73.   vScale:=10;
  74.   SetImport('Text');
  75.   SetImportMinMax(-4,8);
  76.   Import('');       {Prompt for file name}
  77.   GetPicSize(nDays,SamplesPerDay);
  78.   SelectAll;
  79.   ScaleSelection(1,hscale);
  80.   RestoreRoi;
  81.   Copy;
  82.   Dispose(nPics);
  83.   width:=SamplesPerDay*hScale;
  84.   if DoublePlot then width:=width*2;
  85.   height:=nDays*vScale;
  86.   if width>height
  87.     then height:=width;
  88.   SetNewSize(width+80,height+40);
  89.   SetBackgroundColor(0); 
  90.   MakeNewWindow('Sleep Data');
  91.   Paste;
  92.   RestoreRoi;
  93.   SetOption; RotateLeft; {Erase before rotating}
  94.   FlipVertical;
  95.   ScaleSelection(1,vScale);
  96.   RestoreRoi;
  97.   GetRoi(x,y,RoiWidth,RoiHeight);
  98.   Copy;
  99.   Clear;
  100.   MakeRoi(10,vloc,RoiWidth,RoiHeight);
  101.   Paste;
  102.   if DoublePlot then begin
  103.     MakeRoi(10+RoiWidth,vloc-vscale,RoiWidth,RoiHeight);
  104.     Paste;
  105.   end;
  106.   KillRoi;
  107. end;
  108.  
  109.  
  110. macro 'Import Sleep Data';
  111. var
  112.   DoublePlot:boolean;
  113. begin
  114.   DoublePlot:=false;
  115.   ImportSleepData;
  116. end;
  117.  
  118.  
  119. macro 'Import Sleep Data - Double Plot';
  120. var
  121.   DoublePlot:boolean;
  122. begin
  123.   DoublePlot:=true;
  124.   ImportSleepData;
  125. end;
  126.  
  127.  
  128. macro 'Draw Sleep Scale';
  129. var
  130.   width,height,hloc,vloc,vdelta:integer;
  131.   PicWidth,PicHeight:integer;
  132. begin
  133.   SetFont('Helvetica');
  134.   SetFontSize(9);
  135.   SetText('Plain; Center; no background');
  136.   SetLineWidth(1);
  137.   width:=28;
  138.   height:=28;
  139.   GetPicSize(PicWidth,PicHeight);
  140.   hloc:=PicWidth-width-10;
  141.   vloc:=15;
  142.   vdelta:=height-1;
  143.   DrawBox(1,-4);
  144.   DrawBox(22,-3);
  145.   DrawBox(43,-2);
  146.   DrawBox(75,-1);
  147.   DrawBox(85,0);
  148.   DrawBox(87,.1);
  149.   DrawBox(96,.5);
  150.   DrawBox(106,1);
  151.   DrawBox(128,2);
  152.   DrawBox(149,3);
  153.   DrawBox(170,4);
  154.   DrawBox(191,5);
  155.   DrawBox(212,6);
  156.   DrawBox(233,7);
  157.   DrawBox(248,8);
  158.  end;
  159.  
  160. macro '(-'; begin end;
  161.  
  162.  
  163. macro '(....Edit Sleep Data....'; begin end;
  164.  
  165.  
  166. procedure Setup;
  167. begin
  168.   MakeRoi(left,top,width,height);
  169.   Copy;
  170.   Paste;
  171. end;
  172.  
  173. macro 'Top [T]'
  174. var
  175.   PicWidth,PicHeight:integer;
  176. begin
  177.   GetPicSize(PicWidth,PicHeight);
  178.   left:=5;
  179.   top:=10;
  180.   width:=PicWidth-left-20;;
  181.   HeightOne:=10;
  182.   Height:=HeightOne;
  183.   SetUp;
  184. end;
  185.  
  186. macro 'Move Down [D]'
  187. begin
  188.   Top:=top+10;
  189.   SetUp;
  190. end;
  191.  
  192. macro 'Move Up [U]'
  193. begin
  194.   Top:=top-10;
  195.   SetUp;
  196. end;
  197.  
  198. macro 'One [1]';
  199. begin
  200.   height:=HeightOne;
  201.   SetUp;
  202. end;
  203.  
  204. macro 'Two [2]';
  205. begin
  206.   height:=2*HeightOne;
  207.   SetUp;
  208. end;
  209.  
  210. macro 'Three [3]';
  211. begin
  212.   height:=3*HeightOne;
  213.   SetUp;
  214. end;
  215.  
  216. macro 'Four [4]';
  217. begin
  218.   height:=4*HeightOne;
  219.   SetUp;
  220. end;
  221.  
  222. macro 'Five [5]';
  223. begin
  224.   height:=5*HeightOne;
  225.   SetUp;
  226. end;
  227.  
  228. macro 'Six [6]';
  229. begin
  230.   height:=6*HeightOne;
  231.   SetUp;
  232. end;
  233.  
  234. procedure DrawBox(BoxColor:integer; BoxLabel:real);
  235. begin
  236.   MakeRoi(hloc,vloc,width,height);
  237.   SetForeground(BoxColor);
  238.   Fill;
  239.   SetForeground(255);
  240.   DrawBoundary;
  241.   MoveTo(hloc+11,vloc+11);
  242.   Writeln(BoxLabel);
  243.   vloc:=vloc+vdelta;
  244. end;
  245.